#include "../include/Move.h"


singleMove::singleMove(int xD, int yD, int xA, int yA, int No)
{
    xDepart = xD;
    yDepart = yD;
    xArrivee = xA;
    yArrivee = yA;
    nombre = No;
 }

 void singleMove::printMove()
 {
     std::cout << "Move N=" << nombre << " (" << xDepart << "," << yDepart << ")->(" << xArrivee << "," << yArrivee << ")" << std::endl;
 }


moves::moves()
{
    isUsed = false;
}

void moves::addMove(int xDepart, int yDepart, int xArrivee, int yArrivee, int nombre)
{
    isUsed = true;
    singleMove currentMove = singleMove(xDepart, yDepart, xArrivee, yArrivee, nombre);
    if (movesList.size() < 3)
    {
        movesList.push_back(currentMove);
    }
    else
    {
        std::cout << "ERREUR : 3 Mouvements maximum par tour" << std::endl;
    }
}

void moves::addMove(singleMove currentMove)
{
    isUsed = true;
    if (movesList.size() < 3)
    {
        movesList.push_back(currentMove);
    }
    else
    {
        std::cout << "ERREUR : 3 Mouvements maximum par tour" << std::endl;
    }
}

void moves::flushMoves()
{
    movesList.clear();
    isUsed = false;
}

std::vector <int> moves::getContentToSend()
{
    std::vector <int> list;
    int N = movesList.size();
    list.push_back(N);

    for( std::vector<singleMove>::iterator it = movesList.begin(); it != movesList.end(); it++ )
    {
        list.push_back( (*it).xDepart );
        list.push_back( (*it).yDepart );
        list.push_back( (*it).nombre );
        list.push_back( (*it).xArrivee );
        list.push_back( (*it).yArrivee );
    }

    return list;

}
